package com.agger.eurekacommonapi.vo;

import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
 * @classname: ResultData
 * @description: 返回结果类
 * @author chenhx
 * @date 2020-04-23 10:21:16
 */
@Data
@Accessors(chain = true)
public class ResultData<T> implements Serializable {

    private Boolean ret;
    private String message;
    private T data;
    private Throwable throwable;

    public static <T> ResultData<T> FAILED() {
        return new ResultData().setRet(false);
    }
    public static <T> ResultData<T> FAILED(String message) {
        return new ResultData().setRet(false).setMessage(message);
    }
    public static <T> ResultData<T> FAILED(String message,Throwable throwable) {
        return new ResultData().setRet(false).setMessage(message).setThrowable(throwable);
    }
    public static <T> ResultData<T> SUCCESS() {
        return new ResultData().setRet(true);
    }
    public static <T> ResultData<T> SUCCESS(T data) {
        return new ResultData().setRet(true).setData(data);
    }
}